﻿/* Name: BaseTest.cs
 * Project: Sirocco Team Collaboration Software
 * Author: Anthony Chang
 * Creation Date: 2010-11-11
 * Copyright: (c) 2010 by Sirocco Software
 * License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt)
 */

using NHibernate;
using NHibernate.Tool.hbm2ddl;
using Sirocco.Data.Helper;

namespace SiroccoTest.Common
{
    /// <summary>
    /// Base class for all the tests
    /// </summary>
    public class BaseTest
    {
        public NHibernateSessionManager SessionManager = NHibernateSessionManager.Instance;
        
        public BaseTest()
        {
            CreateDatabase();
        }

        public ISession GetSession()
        {
            return SessionManager.GetSession();
        }

        public void CreateDatabase()
        {
            var sess = GetSession();
            var conn = sess.Connection;

            var schemaExport = new SchemaExport(SessionManager.GetConfiguration());
            schemaExport.Execute(true, true, false,conn,null);
        }

    //    [TestMethod]
    //    // Todo: [Write]
    //    public void DateTime_Test()
    //    {
    //        string dateString;
    //        CultureInfo culture;
    //        DateTimeStyles styles;
    //        DateTime dateResult;

    //        // Parse a date and time with no styles.
    //        dateString = "03/01/2009 10:00 AM";
    //        culture = CultureInfo.CreateSpecificCulture("en-MY");
    //        styles = DateTimeStyles.None;
    //        if (DateTime.TryParse(dateString, culture, styles, out dateResult))
    //            Console.WriteLine("{0} converted to {1} {2}.",
    //                              dateString, dateResult, dateResult.Kind);
    //        else
    //            Console.WriteLine("Unable to convert {0} to a date and time.",
    //                              dateString);

    //        // Parse the same date and time with the AssumeLocal style.
    //        styles = DateTimeStyles.AssumeLocal;
    //        if (DateTime.TryParse(dateString, culture, styles, out dateResult))
    //            Console.WriteLine("{0} converted to {1} {2}.",
    //                              dateString, dateResult, dateResult.Kind);
    //        else
    //            Console.WriteLine("Unable to convert {0} to a date and time.", dateString);

    //        // Parse a date and time that is assumed to be local.
    //        // This time is five hours behind UTC. The local system's time zone is 
    //        // eight hours behind UTC.
    //        dateString = "2009/03/01T10:00:00-5:00";
    //        styles = DateTimeStyles.AssumeLocal;
    //        if (DateTime.TryParse(dateString, culture, styles, out dateResult))
    //            Console.WriteLine("{0} converted to {1} {2}.",
    //                              dateString, dateResult, dateResult.Kind);
    //        else
    //            Console.WriteLine("Unable to convert {0} to a date and time.", dateString);

    //        // Attempt to convert a string in improper ISO 8601 format.
    //        dateString = "03/01/2009T10:00:00-5:00";
    //        if (DateTime.TryParse(dateString, culture, styles, out dateResult))
    //            Console.WriteLine("{0} converted to {1} {2}.",
    //                              dateString, dateResult, dateResult.Kind);
    //        else
    //            Console.WriteLine("Unable to convert {0} to a date and time.", dateString);

    //        // Assume a date and time string formatted for the fr-FR culture is the local 
    //        // time and convert it to UTC.
    //        dateString = "2008-03-01 10:00";
    //        culture = CultureInfo.CreateSpecificCulture("fr-FR");
    //        styles = DateTimeStyles.AdjustToUniversal | DateTimeStyles.AssumeLocal;
    //        if (DateTime.TryParse(dateString, culture, styles, out dateResult))
    //            Console.WriteLine("{0} converted to {1} {2}.",
    //                              dateString, dateResult, dateResult.Kind);
    //        else
    //            Console.WriteLine("Unable to convert {0} to a date and time.", dateString);

    //        // The example displays the following output to the console:
    //        //       03/01/2009 10:00 AM converted to 3/1/2009 10:00:00 AM Unspecified.
    //        //       03/01/2009 10:00 AM converted to 3/1/2009 10:00:00 AM Local.
    //        //       2009/03/01T10:00:00-5:00 converted to 3/1/2009 7:00:00 AM Local.
    //        //       Unable to convert 03/01/2009T10:00:00-5:00 to a date and time.
    //        //       2008-03-01 10:00 converted to 3/1/2008 6:00:00 PM Utc.

    //    }

    //    // Todo: [Move] to Global String Manipulation.
    //    private String FormatValue(String value)
    //    {
    //        if (String.IsNullOrEmpty(value))
    //        {
    //            return (value == null) ? "[NULL]" : "[EMPTY]";
    //        }
    //        return ">" + value + "<";
    //    }
       }
    }
